#ifndef __IOPMP_CFG_H_
#define __IOPMP_CFG_H_

typedef struct
{
  uint32_t  begin_cnt;
  uint32_t size_cnt;
  uint32_t rule;
  uint32_t mode;
}diopmp_config;

//*******************************
//          IOPMP
//*******************************
#define IOPMP_BASE            0xF0400000
#define IOPMP_ID_REG          0X00
#define SIOPMP_RULE_REG       0X04
#define DIOPMP_BEGIN_CNT_REG  0X08
#define DIOPMP_DSIZE_CNT_REG  0X0C
#define DIOPMP_RULE_REG       0X10
#define DIOPMP_MODE_REG       0X14
#define SDIOPMP_ERROR_REG     0X18

#define DMA_BY_DEP  0xfff
#define DMA_REE_INC_START_PC 0xf0000000 //ree的程序在tee的iram中的地址
#define DMA_BY_DEST_BASE     0x20025000 //定义dest地址
#define DMA_BY_SRC_BASE      0x00008000//定义src地址
#define DMA_BLK_NUM          0X01      //DMA搬移block的数量

//*******************************
//          USI0 UART
//*******************************
#define USI0_BADDR  0x50028000
#define USI2_BADDR  0x50029000

#define USI1_BADDR  0x60028000
#define REG32(addr) *((volatile unsigned int *)(addr))

#define USI_CTRL    0x00
#define MODE_SEL    0x04
#define TX_FIFO     0x08
#define RX_FIFO     0x08
#define FIFO_STA    0x0c
#define CLK_DIV0    0x10
#define UART_CTRL   0x18
#define UART_STA    0x1c
//*******************************
//          SRAM
//*******************************
#define SRAM_BASE_ADDR 0x50024000
#define ONEKB_ADDR 0x400

enum Device_APB0
{
    TIM0 = 0,
    TIM2,
    TIM4,
    TIM6,
    USI0,
    USI2,
    Flash_ctrl,
    WDT,
    Dummy1,
    Dummy2,
    Dummy3,
    Dummy4,
    PWM,
    Dummy5,
    SRAM,
    Dummy7
};

enum Device_APB1
{
    TIM1=0,
    TIM3,
    TIM5,
    TIM7,
    USI1,
    GPIO,
    RTC  ,
    Dummy8,
    Dummy9,
    Dummy10,
    Dummy11,
    Dummy12,
    Dummy13,
    Dummy14,
    Dummy15,
    PMU
};

enum Rule_wr
{
   READ = 0x1,
   WRITE = 0x2,
   READ_WRITE = 0x3
};

extern void iopmp_config_enable(char iopmpID,unsigned int en_disen);
extern void diopmp_rule_set(char Device,diopmp_config *diopmp_config );
extern uint32_t siopmp_rule_read(void);
extern void diopmp_rule_read(void);

#endif